package com.baoyouqun.controller.back;

import com.alibaba.cola.dto.Response;
import com.alibaba.cola.dto.SingleResponse;
import com.baoyouqun.domain.VO.*;
import com.baoyouqun.service.SystemConfigService;
import io.swagger.annotations.ApiOperation;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/back/api/system/config")
public class SystemConfigController {

    @Resource
    private SystemConfigService systemConfigService;

    @ApiOperation("后台角色与权限配置获取")
    @GetMapping("/background-role-permission")
    public SingleResponse<BackgroundRolePermissionDTO> getBackgroundRolePermission() {
        return SingleResponse.of(systemConfigService.getBackgroundRolePermission());
    }

    @ApiOperation("后台角色与权限配置")
    @PutMapping("/background-role-permission")
    public Response updateBackgroundRolePermission(@RequestBody BackgroundRolePermissionDTO dto) {
        systemConfigService.updateBackgroundRolePermission(dto);
        return Response.buildSuccess();
    }

    @ApiOperation("邀请好友配置获取")
    @GetMapping("/invite-friend")
    public SingleResponse<InviteFriendDTO> getInviteFriend() {
        return SingleResponse.of(systemConfigService.getInviteFriend());
    }

    @ApiOperation("邀请好友配置")
    @PutMapping("/invite-friend")
    public Response updateInviteFriend(@RequestBody InviteFriendDTO dto) {
        systemConfigService.updateInviteFriend(dto);
        return Response.buildSuccess();
    }

    @ApiOperation("添加好友配置获取")
    @GetMapping("/add-friend")
    public SingleResponse<AddFriendDTO> getAddFriend() {
        return SingleResponse.of(systemConfigService.getAddFriend());
    }

    @ApiOperation("添加好友配置")
    @PutMapping("/add-friend")
    public Response updateAddFriend(@RequestBody AddFriendDTO dto) {
        systemConfigService.updateAddFriend(dto);
        return Response.buildSuccess();
    }

    @ApiOperation("发布帖子配置获取")
    @GetMapping("/publish-post")
    public SingleResponse<PublishPostDTO> getPublishPost() {
        return SingleResponse.of(systemConfigService.getPublishPost());
    }

    @ApiOperation("发布帖子配置")
    @PutMapping("/publish-post")
    public Response updatePublishPost(@RequestBody PublishPostDTO dto) {
        systemConfigService.updatePublishPost(dto);
        return Response.buildSuccess();
    }

    @ApiOperation("非豹友访问时长配置获取")
    @GetMapping("/non-leopard-visit")
    public SingleResponse<NonLeopardVisitDTO> getNonLeopardVisit() {
        return SingleResponse.of(systemConfigService.getNonLeopardVisit());
    }

    @ApiOperation("非豹友访问时长配置")
    @PutMapping("/non-leopard-visit")
    public Response updateNonLeopardVisit(@RequestBody NonLeopardVisitDTO dto) {
        systemConfigService.updateNonLeopardVisit(dto);
        return Response.buildSuccess();
    }

    @ApiOperation("VIP会员配置获取")
    @GetMapping("/vip-member")
    public SingleResponse<VipMemberDTO> getVipMember() {
        return SingleResponse.of(systemConfigService.getVipMember());
    }

    @ApiOperation("VIP会员配置")
    @PutMapping("/vip-member")
    public Response updateVipMember(@RequestBody VipMemberDTO dto) {
        systemConfigService.updateVipMember(dto);
        return Response.buildSuccess();
    }

    @ApiOperation("虚拟通话配置获取")
    @GetMapping("/virtual-call")
    public SingleResponse<VirtualCallDTO> getVirtualCall() {
        return SingleResponse.of(systemConfigService.getVirtualCall());
    }

    @ApiOperation("虚拟通话配置")
    @PutMapping("/virtual-call")
    public Response updateVirtualCall(@RequestBody VirtualCallDTO dto) {
        systemConfigService.updateVirtualCall(dto);
        return Response.buildSuccess();
    }

    @ApiOperation("用户协议获取")
    @GetMapping("/user-agreement")
    public SingleResponse<UserAgreementDTO> getUserAgreement() {
        return SingleResponse.of(systemConfigService.getUserAgreement());
    }

    @ApiOperation("用户协议")
    @PutMapping("/user-agreement")
    public Response updateUserAgreement(@RequestBody UserAgreementDTO dto) {
        systemConfigService.updateUserAgreement(dto);
        return Response.buildSuccess();
    }

    @ApiOperation("隐私政策获取")
    @GetMapping("/privacy-policy")
    public SingleResponse<PrivacyPolicyDTO> getPrivacyPolicy() {
        return SingleResponse.of(systemConfigService.getPrivacyPolicy());
    }

    @ApiOperation("隐私政策")
    @PutMapping("/privacy-policy")
    public Response updatePrivacyPolicy(@RequestBody PrivacyPolicyDTO dto) {
        systemConfigService.updatePrivacyPolicy(dto);
        return Response.buildSuccess();
    }

    @ApiOperation("服务条款获取")
    @GetMapping("/service-terms")
    public SingleResponse<ServiceTermsDTO> getServiceTerms() {
        return SingleResponse.of(systemConfigService.getServiceTerms());
    }

    @ApiOperation("服务条款")
    @PutMapping("/service-terms")
    public Response updateServiceTerms(@RequestBody ServiceTermsDTO dto) {
        systemConfigService.updateServiceTerms(dto);
        return Response.buildSuccess();
    }

    @ApiOperation("注册权益获取")
    @GetMapping("/getRegistrationBenefitss")
    public SingleResponse<ServiceTermsDTO> getRegistrationBenefitss() {
        return SingleResponse.of(systemConfigService.getRegistrationBenefitss());
    }

    @ApiOperation("注册权益")
    @PutMapping("/registrationBenefitss")
    public Response updateRegistrationBenefitss(@RequestBody ServiceTermsDTO dto) {
        systemConfigService.updateRegistrationBenefitss(dto);
        return Response.buildSuccess();
    }

    @ApiOperation("公司理念获取")
    @GetMapping("/companyPhilosophy")
    public SingleResponse<ServiceTermsDTO> getCompanyPhilosophy() {
        return SingleResponse.of(systemConfigService.getCompanyPhilosophy());
    }

    @ApiOperation("公司理念")
    @PutMapping("/companyPhilosophy")
    public Response updateCompanyPhilosophy(@RequestBody ServiceTermsDTO dto) {
        systemConfigService.updateCompanyPhilosophy(dto);
        return Response.buildSuccess();
    }

    @ApiOperation("帖子类型配置获取")
    @GetMapping("/post-type")
    public SingleResponse<PostTypeDTO> getPostType() {
        return SingleResponse.of(systemConfigService.getPostType());
    }

    @ApiOperation("帖子类型配置")
    @PutMapping("/post-type")
    public Response updatePostType(@RequestBody PostTypeDTO dto) {
        systemConfigService.updatePostType(dto);
        return Response.buildSuccess();
    }

    @ApiOperation("豹子号规则配置获取")
    @GetMapping("/leopard-number-rule")
    public SingleResponse<LeopardNumberRuleDTO> getLeopardNumberRule() {
        return SingleResponse.of(systemConfigService.getLeopardNumberRule());
    }

    @ApiOperation("豹子号规则配置")
    @PutMapping("/leopard-number-rule")
    public Response updateLeopardNumberRule(@RequestBody LeopardNumberRuleDTO dto) {
        systemConfigService.updateLeopardNumberRule(dto);
        return Response.buildSuccess();
    }


    /**
     * 阿里云短信模板配置（ID+内容）更新
     */
    @ApiOperation("阿里云短信模板配置（ID+内容）")
    @PutMapping("/sms-template")
    public Response updateSmsTemplate(@RequestBody SmsTemplateDTO dto) {
        systemConfigService.updateSmsTemplate(dto);
        return Response.buildSuccess();
    }

    /**
     * （可选）查询当前阿里云短信模板配置（ID+内容）
     */
    @ApiOperation("查询阿里云短信模板配置（ID+内容）")
    @GetMapping("/sms-template")
    public SmsTemplateDTO getSmsTemplate() {
        return systemConfigService.getSmsTemplate();
    }
}